import request from '../utils/request';
import { API_PATHS } from '../constants/api';

// 资源列表查询参数
export interface AssetsListParams {
  current?: number;
  size?: number;
  assetName?: string;
  assetType?: string;
  status?: string;
  [key: string]: any;
}

// 资源信息接口
export interface AssetInfo {
  id: string;
  assetName: string;
  assetCode: string;
  assetType: string;
  status: string;
  description: string;
  provider: string;
  updateFrequency: string;
  dataSize: string;
  createdAt: string;
  updatedAt: string;
}

// 资源详情接口
export interface AssetDetail extends AssetInfo {
  dataFields: Array<{
    fieldName: string;
    fieldType: string;
    description: string;
    isRequired: boolean;
  }>;
  sampleData: any;
  documentation: string;
  attachments: Array<{
    name: string;
    url: string;
  }>;
}

// 分页响应接口
export interface PaginationResponse<T> {
  records: T[];
  total: number;
  size: number;
  current: number;
}

// 获取资源列表
export async function getAssetsList(params: AssetsListParams): Promise<PaginationResponse<AssetInfo>> {
  const response = await request.post(API_PATHS.ASSETS.LIST, params);
  return response.data;
}

// 获取资源详情
export async function getAssetDetail(assetId: string): Promise<AssetDetail> {
  const response = await request.get(API_PATHS.ASSETS.DETAIL(assetId));
  return response.data;
} 